﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TEKYS
    {
        public TEKYS()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VEKPOS();
            this.DataContext = MV;
            InitializeComponent();
            if (!TBMain.Columns.Contains("PART"))
            {
                TBMain.Columns.Add("PART");
                TBMain.Columns.Add("PVAR");
                TBMain.Columns.Add("PFARBE");
            }
        }
        public override void LOADBYAUF()
        {
            if (!IsAuto)
                return;
            TBMain.Clear();
            if (ORDERNUM.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["EKPMANDANT"] = app.Mandant;
            dwData["EKPAUFKRS"] = ORDERNUM.Substring(0, 2);
            dwData["EKPAUFLFD"] = ORDERNUM.Substring(2, 6);
            dwData["EKPAUFPOS"] = ORDERNUM.Substring(8, 3);
            SResult = TMV.QEK12(dwData);
            MergeData(SResult, true, true);
            base.LOADBYAUF();
        }

        public override void OnAutoChg(bool value)
        {
            LOADBYAUF();
            base.OnAutoChg(value);
        }

    }
}
